package com.wisezone.HomeWork.home05;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class InetAddressll {
    public static void main(String[] args) {
        InetAddress address_1= null;
        try {
            address_1 = InetAddress.getByName("www.bangetc.com");
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        System.out.println(address_1);
        //获取InetAddress对象所含的域名
        System.out.println(address_1.getHostName());
        //获取InetAddress对象所含的IP地址
        System.out.println(address_1.getHostAddress());

        InetAddress address_2 = null;
        try {
            address_2 = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        System.out.println(address_2);
    }

}
